<template>
  <el-dialog
    :title="!dataForm.id ? '新增' : '修改'"
    :close-on-click-modal="false"
    :visible.sync="visible">
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
    <el-form-item label="部门ID" prop="htDeptId">
      <el-input v-model="dataForm.htDeptId" placeholder="部门ID"></el-input>
    </el-form-item>
    <el-form-item label="部门名称" prop="htDeptName">
      <el-input v-model="dataForm.htDeptName" placeholder="部门名称"></el-input>
    </el-form-item>
    <el-form-item label="合同类型（合同、任务）" prop="htLx">
      <el-input v-model="dataForm.htLx" placeholder="合同类型（合同、任务）"></el-input>
    </el-form-item>
    <el-form-item label="合同有效期起（年月日）" prop="htYxqq">
      <el-input v-model="dataForm.htYxqq" placeholder="合同有效期起（年月日）"></el-input>
    </el-form-item>
    <el-form-item label="合同有效期止（年月日）" prop="htYxqz">
      <el-input v-model="dataForm.htYxqz" placeholder="合同有效期止（年月日）"></el-input>
    </el-form-item>
    <el-form-item label="签订级别（1一级合同、2二级合同、3三级合同、4四级合同、5五级合同）" prop="htQdjb">
      <el-input v-model="dataForm.htQdjb" placeholder="签订级别（1一级合同、2二级合同、3三级合同、4四级合同、5五级合同）"></el-input>
    </el-form-item>
    <el-form-item label="合同签订日期（年月日）" prop="htQdrq">
      <el-input v-model="dataForm.htQdrq" placeholder="合同签订日期（年月日）"></el-input>
    </el-form-item>
    <el-form-item label="合同年份" prop="htNf">
      <el-input v-model="dataForm.htNf" placeholder="合同年份"></el-input>
    </el-form-item>
    <el-form-item label="合同模式（1多人共享、2多人独享）" prop="htMs">
      <el-input v-model="dataForm.htMs" placeholder="合同模式（1多人共享、2多人独享）"></el-input>
    </el-form-item>
    <el-form-item label="考核周期（1年度、2季度、3月度）" prop="htZq">
      <el-input v-model="dataForm.htZq" placeholder="考核周期（1年度、2季度、3月度）"></el-input>
    </el-form-item>
    <el-form-item label="考核周期暑期（1第一季度、2第二季度、3第三季度、4第四季度、01一月、02二月、03三月、04四月、05五月、06六月、07七月、08八月、09九月、10十月、11十一月、12十二月）" prop="htZqsq">
      <el-input v-model="dataForm.htZqsq" placeholder="考核周期暑期（1第一季度、2第二季度、3第三季度、4第四季度、01一月、02二月、03三月、04四月、05五月、06六月、07七月、08八月、09九月、10十月、11十一月、12十二月）"></el-input>
    </el-form-item>
    <el-form-item label="受约对象（1机构、2个人）" prop="htSydx">
      <el-input v-model="dataForm.htSydx" placeholder="受约对象（1机构、2个人）"></el-input>
    </el-form-item>
    <el-form-item label="发约人名称集合" prop="htFyrNames">
      <el-input v-model="dataForm.htFyrNames" placeholder="发约人名称集合"></el-input>
    </el-form-item>
    <el-form-item label="受约对象名称集合" prop="htSyNames">
      <el-input v-model="dataForm.htSyNames" placeholder="受约对象名称集合"></el-input>
    </el-form-item>
    <el-form-item label="合同步骤（1合同创建、2合同审核、3签订审核、4结果填报、5预填报审核、6填报审核）" prop="htBz">
      <el-input v-model="dataForm.htBz" placeholder="合同步骤（1合同创建、2合同审核、3签订审核、4结果填报、5预填报审核、6填报审核）"></el-input>
    </el-form-item>
    <el-form-item label="合同创建状态（未提交、已提交、已驳回）" prop="htCjzt">
      <el-input v-model="dataForm.htCjzt" placeholder="合同创建状态（未提交、已提交、已驳回）"></el-input>
    </el-form-item>
    <el-form-item label="合同创建说明" prop="htCjsm">
      <el-input v-model="dataForm.htCjsm" placeholder="合同创建说明"></el-input>
    </el-form-item>
    <el-form-item label="合同审核状态（未开始、审批中、审批通过、审核不通过、已驳回）" prop="htShzt">
      <el-input v-model="dataForm.htShzt" placeholder="合同审核状态（未开始、审批中、审批通过、审核不通过、已驳回）"></el-input>
    </el-form-item>
    <el-form-item label="合同审核类型" prop="htShlx">
      <el-input v-model="dataForm.htShlx" placeholder="合同审核类型"></el-input>
    </el-form-item>
    <el-form-item label="合同审核ID" prop="htShid">
      <el-input v-model="dataForm.htShid" placeholder="合同审核ID"></el-input>
    </el-form-item>
    <el-form-item label="合同审核说明" prop="htShsm">
      <el-input v-model="dataForm.htShsm" placeholder="合同审核说明"></el-input>
    </el-form-item>
    <el-form-item label="签订审核状态（未开始、确定签订中、审批中、审批通过、审核不通过、已驳回）" prop="htQdshzt">
      <el-input v-model="dataForm.htQdshzt" placeholder="签订审核状态（未开始、确定签订中、审批中、审批通过、审核不通过、已驳回）"></el-input>
    </el-form-item>
    <el-form-item label="签订审核类型" prop="htQdshlx">
      <el-input v-model="dataForm.htQdshlx" placeholder="签订审核类型"></el-input>
    </el-form-item>
    <el-form-item label="签订审核ID" prop="htQdshid">
      <el-input v-model="dataForm.htQdshid" placeholder="签订审核ID"></el-input>
    </el-form-item>
    <el-form-item label="签订审核说明" prop="htQdshsm">
      <el-input v-model="dataForm.htQdshsm" placeholder="签订审核说明"></el-input>
    </el-form-item>
    <el-form-item label="预填报审核状态（填报中、审批中、审批通过、审核不通过）" prop="htYtbshzt">
      <el-input v-model="dataForm.htYtbshzt" placeholder="预填报审核状态（填报中、审批中、审批通过、审核不通过）"></el-input>
    </el-form-item>
    <el-form-item label="预填报审核类型" prop="htYtbshlx">
      <el-input v-model="dataForm.htYtbshlx" placeholder="预填报审核类型"></el-input>
    </el-form-item>
    <el-form-item label="预填报审核ID" prop="htYtbshid">
      <el-input v-model="dataForm.htYtbshid" placeholder="预填报审核ID"></el-input>
    </el-form-item>
    <el-form-item label="预填报审核说明" prop="htYtbshsm">
      <el-input v-model="dataForm.htYtbshsm" placeholder="预填报审核说明"></el-input>
    </el-form-item>
    <el-form-item label="填报审核状态（填报中、审批中、审批通过、审核不通过）" prop="htTbshzt">
      <el-input v-model="dataForm.htTbshzt" placeholder="填报审核状态（填报中、审批中、审批通过、审核不通过）"></el-input>
    </el-form-item>
    <el-form-item label="填报审核类型" prop="htTbshlx">
      <el-input v-model="dataForm.htTbshlx" placeholder="填报审核类型"></el-input>
    </el-form-item>
    <el-form-item label="填报审核ID" prop="htTbshid">
      <el-input v-model="dataForm.htTbshid" placeholder="填报审核ID"></el-input>
    </el-form-item>
    <el-form-item label="填报审核说明" prop="htTbshsm">
      <el-input v-model="dataForm.htTbshsm" placeholder="填报审核说明"></el-input>
    </el-form-item>
    <el-form-item label="合同任务删除原因" prop="htScyy">
      <el-input v-model="dataForm.htScyy" placeholder="合同任务删除原因"></el-input>
    </el-form-item>
    <el-form-item label="预填报成绩推送状态（1已推送、0未推送）" prop="htYtbcjts">
      <el-input v-model="dataForm.htYtbcjts" placeholder="预填报成绩推送状态（1已推送、0未推送）"></el-input>
    </el-form-item>
    <el-form-item label="填报成绩推送状态（1已推送、0未推送）" prop="htTbcjts">
      <el-input v-model="dataForm.htTbcjts" placeholder="填报成绩推送状态（1已推送、0未推送）"></el-input>
    </el-form-item>
    <el-form-item label="建立时间" prop="createTime">
      <el-input v-model="dataForm.createTime" placeholder="建立时间"></el-input>
    </el-form-item>
    <el-form-item label="建立部门ID" prop="createDeptId">
      <el-input v-model="dataForm.createDeptId" placeholder="建立部门ID"></el-input>
    </el-form-item>
    <el-form-item label="建立部门" prop="createDeptName">
      <el-input v-model="dataForm.createDeptName" placeholder="建立部门"></el-input>
    </el-form-item>
    <el-form-item label="建立人员ID" prop="createUserId">
      <el-input v-model="dataForm.createUserId" placeholder="建立人员ID"></el-input>
    </el-form-item>
    <el-form-item label="建立人员" prop="createUserName">
      <el-input v-model="dataForm.createUserName" placeholder="建立人员"></el-input>
    </el-form-item>
    <el-form-item label="修改时间" prop="editTime">
      <el-input v-model="dataForm.editTime" placeholder="修改时间"></el-input>
    </el-form-item>
    <el-form-item label="修改部门ID" prop="editDeptId">
      <el-input v-model="dataForm.editDeptId" placeholder="修改部门ID"></el-input>
    </el-form-item>
    <el-form-item label="修改部门" prop="editDeptName">
      <el-input v-model="dataForm.editDeptName" placeholder="修改部门"></el-input>
    </el-form-item>
    <el-form-item label="修改人员ID" prop="editUserId">
      <el-input v-model="dataForm.editUserId" placeholder="修改人员ID"></el-input>
    </el-form-item>
    <el-form-item label="修改人员" prop="editUserName">
      <el-input v-model="dataForm.editUserName" placeholder="修改人员"></el-input>
    </el-form-item>
    <el-form-item label="数据状态（0删除、1正常）" prop="dataState">
      <el-input v-model="dataForm.dataState" placeholder="数据状态（0删除、1正常）"></el-input>
    </el-form-item>
    <el-form-item label="所属租户" prop="tenantId">
      <el-input v-model="dataForm.tenantId" placeholder="所属租户"></el-input>
    </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button type="primary" @click="dataFormSubmit()" v-if="canSubmit">确定</el-button>
      <el-button @click="visible = false">取消</el-button>
    </span>
  </el-dialog>
</template>

<script>
    import {getObj, addObj, putObj,addObj_wf} from '@/api/hetongrenwu/hetonghtxxdjb-sp'

    export default {
    data () {
      return {
        visible: false,
        canSubmit: false,
        dataForm: {
          id: 0,
          htDeptId: '',
          htDeptName: '',
          htLx: '',
          htYxqq: '',
          htYxqz: '',
          htQdjb: '',
          htQdrq: '',
          htNf: '',
          htMs: '',
          htZq: '',
          htZqsq: '',
          htSydx: '',
          htFyrNames: '',
          htSyNames: '',
          htBz: '',
          htCjzt: '',
          htCjsm: '',
          htShzt: '',
          htShlx: '',
          htShid: '',
          htShsm: '',
          htQdshzt: '',
          htQdshlx: '',
          htQdshid: '',
          htQdshsm: '',
          htYtbshzt: '',
          htYtbshlx: '',
          htYtbshid: '',
          htYtbshsm: '',
          htTbshzt: '',
          htTbshlx: '',
          htTbshid: '',
          htTbshsm: '',
          htScyy: '',
          htYtbcjts: '',
          htTbcjts: '',
          createTime: '',
          createDeptId: '',
          createDeptName: '',
          createUserId: '',
          createUserName: '',
          editTime: '',
          editDeptId: '',
          editDeptName: '',
          editUserId: '',
          editUserName: '',
          dataState: '',
          tenantId: ''
        },
        dataRule: {
          htDeptId: [
            { required: true, message: '部门ID不能为空', trigger: 'blur' }
          ],
          htDeptName: [
            { required: true, message: '部门名称不能为空', trigger: 'blur' }
          ],
          htLx: [
            { required: true, message: '合同类型（合同、任务）不能为空', trigger: 'blur' }
          ],
          htYxqq: [
            { required: true, message: '合同有效期起（年月日）不能为空', trigger: 'blur' }
          ],
          htYxqz: [
            { required: true, message: '合同有效期止（年月日）不能为空', trigger: 'blur' }
          ],
          htQdjb: [
            { required: true, message: '签订级别（1一级合同、2二级合同、3三级合同、4四级合同、5五级合同）不能为空', trigger: 'blur' }
          ],
          htQdrq: [
            { required: true, message: '合同签订日期（年月日）不能为空', trigger: 'blur' }
          ],
          htNf: [
            { required: true, message: '合同年份不能为空', trigger: 'blur' }
          ],
          htMs: [
            { required: true, message: '合同模式（1多人共享、2多人独享）不能为空', trigger: 'blur' }
          ],
          htZq: [
            { required: true, message: '考核周期（1年度、2季度、3月度）不能为空', trigger: 'blur' }
          ],
          htZqsq: [
            { required: true, message: '考核周期暑期（1第一季度、2第二季度、3第三季度、4第四季度、01一月、02二月、03三月、04四月、05五月、06六月、07七月、08八月、09九月、10十月、11十一月、12十二月）不能为空', trigger: 'blur' }
          ],
          htSydx: [
            { required: true, message: '受约对象（1机构、2个人）不能为空', trigger: 'blur' }
          ],
          htFyrNames: [
            { required: true, message: '发约人名称集合不能为空', trigger: 'blur' }
          ],
          htSyNames: [
            { required: true, message: '受约对象名称集合不能为空', trigger: 'blur' }
          ],
          htBz: [
            { required: true, message: '合同步骤（1合同创建、2合同审核、3签订审核、4结果填报、5预填报审核、6填报审核）不能为空', trigger: 'blur' }
          ],
          htCjzt: [
            { required: true, message: '合同创建状态（未提交、已提交、已驳回）不能为空', trigger: 'blur' }
          ],
          htCjsm: [
            { required: true, message: '合同创建说明不能为空', trigger: 'blur' }
          ],
          htShzt: [
            { required: true, message: '合同审核状态（未开始、审批中、审批通过、审核不通过、已驳回）不能为空', trigger: 'blur' }
          ],
          htShlx: [
            { required: true, message: '合同审核类型不能为空', trigger: 'blur' }
          ],
          htShid: [
            { required: true, message: '合同审核ID不能为空', trigger: 'blur' }
          ],
          htShsm: [
            { required: true, message: '合同审核说明不能为空', trigger: 'blur' }
          ],
          htQdshzt: [
            { required: true, message: '签订审核状态（未开始、确定签订中、审批中、审批通过、审核不通过、已驳回）不能为空', trigger: 'blur' }
          ],
          htQdshlx: [
            { required: true, message: '签订审核类型不能为空', trigger: 'blur' }
          ],
          htQdshid: [
            { required: true, message: '签订审核ID不能为空', trigger: 'blur' }
          ],
          htQdshsm: [
            { required: true, message: '签订审核说明不能为空', trigger: 'blur' }
          ],
          htYtbshzt: [
            { required: true, message: '预填报审核状态（填报中、审批中、审批通过、审核不通过）不能为空', trigger: 'blur' }
          ],
          htYtbshlx: [
            { required: true, message: '预填报审核类型不能为空', trigger: 'blur' }
          ],
          htYtbshid: [
            { required: true, message: '预填报审核ID不能为空', trigger: 'blur' }
          ],
          htYtbshsm: [
            { required: true, message: '预填报审核说明不能为空', trigger: 'blur' }
          ],
          htTbshzt: [
            { required: true, message: '填报审核状态（填报中、审批中、审批通过、审核不通过）不能为空', trigger: 'blur' }
          ],
          htTbshlx: [
            { required: true, message: '填报审核类型不能为空', trigger: 'blur' }
          ],
          htTbshid: [
            { required: true, message: '填报审核ID不能为空', trigger: 'blur' }
          ],
          htTbshsm: [
            { required: true, message: '填报审核说明不能为空', trigger: 'blur' }
          ],
          htScyy: [
            { required: true, message: '合同任务删除原因不能为空', trigger: 'blur' }
          ],
          htYtbcjts: [
            { required: true, message: '预填报成绩推送状态（1已推送、0未推送）不能为空', trigger: 'blur' }
          ],
          htTbcjts: [
            { required: true, message: '填报成绩推送状态（1已推送、0未推送）不能为空', trigger: 'blur' }
          ],
          createTime: [
            { required: true, message: '建立时间不能为空', trigger: 'blur' }
          ],
          createDeptId: [
            { required: true, message: '建立部门ID不能为空', trigger: 'blur' }
          ],
          createDeptName: [
            { required: true, message: '建立部门不能为空', trigger: 'blur' }
          ],
          createUserId: [
            { required: true, message: '建立人员ID不能为空', trigger: 'blur' }
          ],
          createUserName: [
            { required: true, message: '建立人员不能为空', trigger: 'blur' }
          ],
          editTime: [
            { required: true, message: '修改时间不能为空', trigger: 'blur' }
          ],
          editDeptId: [
            { required: true, message: '修改部门ID不能为空', trigger: 'blur' }
          ],
          editDeptName: [
            { required: true, message: '修改部门不能为空', trigger: 'blur' }
          ],
          editUserId: [
            { required: true, message: '修改人员ID不能为空', trigger: 'blur' }
          ],
          editUserName: [
            { required: true, message: '修改人员不能为空', trigger: 'blur' }
          ],
          dataState: [
            { required: true, message: '数据状态（0删除、1正常）不能为空', trigger: 'blur' }
          ],
          tenantId: [
            { required: true, message: '所属租户不能为空', trigger: 'blur' }
          ]
        }
      }
    },
    methods: {
      init (id) {
        this.dataForm.id = id || 0;
        this.visible = true;
        this.canSubmit = true;
        this.$nextTick(() => {
          this.$refs['dataForm'].resetFields()
          if (this.dataForm.id) {
            getObj(this.dataForm.id).then(response => {
                this.dataForm = response.data.data
            })
          }
        })
      },
      // 表单提交
      dataFormSubmit () {
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            this.canSubmit = false;
            if (this.dataForm.id) {
                putObj(this.dataForm).then(data => {
                  this.$notify.closeAll();
                    this.$notify.success('修改成功')
                    this.visible = false
                    this.$emit('refreshDataList')
                }).catch(() => {
                    this.canSubmit = true;
                });
            } else {
                addObj_wf(this.dataForm).then(data => {
                  this.$notify.closeAll();
                    this.$notify.success('添加成功')
                    this.visible = false
                    this.$emit('refreshDataList')
                }).catch(() => {
                    this.canSubmit = true;
                });
            }
          }
        })
      }
    }
  }
</script>
